package thread;

public class Demo16 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            System.out.println("running");
            System.out.println(Thread.currentThread().getState()); // RUNNABLE
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("t end");
        });
        System.out.println(t.getState()); // NEW
        t.start();

        t.join(1000);
        System.out.println(t.getState()); // TIMED_WAITING
        t.join();
        System.out.println(t.getState()); // TERMINATED

    }
}
